import { Lv70DramaMapInfo } from "../view/lv70fb/data/Lv70DramaMapInfo";
import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class DramaMapConfig
    
    export  class DramaMapConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            if (DramaMapConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        public DramaMapConfig.get maxChapterNum(): int
        {
            return this._maxMapId;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            var loc4=arg1.map;
            for(loc2 of loc4) 
            {
                loc1 = new Lv70DramaMapInfo();
                loc1.bossNames = String(loc2.bossNames).split("_");
                loc1.bossPlaces = this.toPointArr(String(loc2.bossPlaces));
                loc1.mapNamePlaces = this.toPointArr(String(loc2.mapNamePlaces), -200, -200);
                loc1.mapPlaces = this.toPointArr(String(loc2.mapPlaces));
                loc1.chooseBoxPlace = this.toPoint(loc2.chooseBoxPlace as string);
                loc1.id = loc2.id;
                loc1.haveEasy = loc2.haveEasy;
                loc1.haveDifficulty = loc2.haveDifficulty;
                this._map[loc1.id] = loc1;
                if (!(loc1.id > this._maxMapId)) 
                {
                    continue;
                }
                this._maxMapId = loc1.id;
            }
            return;
        }

        /* internal  */toPointArr(arg1: string, arg2: int=0, arg3: int=0): Array<any>
        {
            var loc1=[];
            var loc2=arg1.split("_");
            var loc3=0;
            while (loc3 < loc2.length) 
            {
                loc1.push(this.toPoint(loc2[loc3] as string, arg2, arg3));
                ++loc3;
            }
            return loc1;
        }

        /* internal  */toPoint(arg1: string, arg2: int=0, arg3: int=0): Object /* flash.geom.Point */
        {
            var loc1=arg1.split(",");
            var loc2;
            (loc2 = new Object /* flash.geom.Point */()).x = parseInt(loc1[0] as string) + arg2;
            loc2.y = parseInt(loc1[1] as string) + arg3;
            return loc2;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getObjectByFileName("dramaMap.xml");
            this.write(loc1);
            return;
        }

        public getMapInfo(arg1: int): Lv70DramaMapInfo
        {
            return this._map[arg1];
        }

        public static get instance(): DramaMapConfig
        {
            if (DramaMapConfig._instance == null) 
            {
                DramaMapConfig._instance = new DramaMapConfig();
            }
            return DramaMapConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_maxMapId: int=1;

        /* internal */ static /* var */_instance: DramaMapConfig;
    }
